package com.woniu.commons.exception.handler;

import com.woniu.commons.response.ResponseResult;
import com.woniu.commons.exception.UnAuthorizationException;
import org.apache.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//全局异常处理器
@RestControllerAdvice
public class GlobalExceptionHandle {

    @ExceptionHandler(UnAuthorizationException.class)
    public ResponseResult<Object> handlerUnAuthorizationException(Exception e){
        return new ResponseResult<>(HttpStatus.SC_UNAUTHORIZED, e.getMessage(), null);
    }
}
